/*
 * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */

package jsr203.nio.file.attribute;

/**
 * An object that encapsulates a value associated with a file system object.
 * Attributes are used to encapsulate the value of file attributes that can be
 * set atomically when creating a new file or directory by invoking the {@link
 * jsr203.nio.file.Path#createFile createFile} or {@link
 * jsr203.nio.file.Path#createDirectory createFile} methods.
 *
 * @param <T> The type of the attribute value
 *
 * @since 1.7
 *
 * @see PosixFileAttributeView#newPermissionsAttribute
 * @see AclFileAttributeView#newAclAttribute
 */

public interface Attribute<T> {
    /**
     * Get the attribute value.
     *
     * <p> If the value is a mutable type then a copy of the value is returned.
     *
     * @return  The attribute value
     */
    T getValue();

    /**
     * Set the attribute value.
     *
     * <p> The value {@code null} may be valid for some attribute types. If the
     * attribute value is a collection and it contains elements that are not of
     * the required type then {@code ClassCastException} may be thrown. If the
     * value is a mutable type then this method copies the value.
     *
     * @param   value
     *          The attribute value
     *
     * @return  This object
     *
     * @throws  IllegalArgumentException
     *          If the attribute value is invalid
     */
    Attribute<T> setValue(T value);
}
